<template>
	<view class="container">
		<view class="status-bar">

		</view>
		<uni-nav-bar left-icon="left" @clickLeft="leftback" title="选择就诊人" :border="false" :height="barhig"
			class="header-title" />
		<view class="content" :style="`padding-top:${systemBarHeight+64}px`">
			<view class="hearde-title">
				<text>请选择就诊人</text>
			</view>
			<view class="person">
				<peosonli v-for="item in personText" :listcon="item" @selectper="selectper" :key="item.patients_id"></peosonli>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		onLoad
	} from '@dcloudio/uni-app';
	import storage from '@/utils/storage.js'
	import peosonli from '@/components/bookingReg/personli/personli.vue'
	import {
		ref,
		reactive,
		toRefs,

	} from 'vue'
	import {setuserList} from '@/utils/axios.js'
	export default {
		components: {
			peosonli
		},
		
		setup() {
			onLoad(()=>{
				
			})
			const userId=storage.get('userId')
			console.log(userId);
			
			const data = reactive({
				personText: [
				],
				huzhedata:[],
				barhig: '120rpx',
				systemBarHeight: null,
			})
			// #ifdef MP-WEIXIN
			const getCapsule = () => {
				// 获取胶囊位置并改变顶部自定义导航栏的位置
				let menuButtonInfo = uni.getMenuButtonBoundingClientRect();
				console.log(menuButtonInfo, '胶囊top位置')
				//让自定义导航栏头部组件始终和胶囊对齐 做到兼容各手机型号
				data.barhig = (menuButtonInfo.top + menuButtonInfo.height) * 2 + 'rpx';
			}
			getCapsule()
			const getSysteminfo = () => {
				uni.getSystemInfo({
					success: res => {
				 	data.systemBarHeight = res.statusBarHeight;
						console.log(data.systemBarHeight, res)
					}
				});
			}
			getSysteminfo()
			// #endif
			const selectper = (obj) => {
				console.log(obj);
				storage.set('hzdata',obj)
				uni.navigateTo({
					url:`/pages/home/bookingReg/deskWork/deskWork?item='${JSON.stringify(obj)}`
				})
			}
			const leftback = () => {
				storage.remove('hzdata')
                   uni.switchTab({
					   url:"/pages/home/index/index"
				   })
			}
            setuserList({userId}).then(res=>{
				
				data.huzhedata=res.data
				data.personText=res.data.list
				data.personText.forEach(item=>{
					let odd=item.patients_id_number.toString().slice(6,15)
					item.patients_id_number=item.patients_id_number.toString().replace(odd,"*******")
				})
				
			})
			return {
				...toRefs(data),
				selectper,
				leftback
			}
		}
	}
</script>

<style lang="scss">
	.status-bar {
		height: var(--status-bar-height);
		width: 100%;
		background-color: #fff;
		position: fixed;
		top: 0;
		z-index: 998999;
	}

	.header-title {
		position: fixed;
		width: 100%;
		top: var(--status-bar-height);
		z-index: 998999;
	}

	.content {
		padding: 24rpx 36rpx;

		.hearde-title {
			margin-bottom: 36rpx;
		}
	}
</style>
